package com.yanqu.road.entity.rank.yrank;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.DataStatus;
import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.entity.union.UnionBaseInfo;

import java.math.BigInteger;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;

@FieldTypeAnnotation(tableName = "t_c_yrank_union")
public class UnionYRank extends DataObject {

    @FieldTypeAnnotation(desc = "活动ID", select = true, update = true)
    private int activityId;

    @FieldTypeAnnotation(desc = "分组ID", update = true)
    private int groupId;

    @FieldTypeAnnotation(desc = "类型", update = true)
    private String idKey = "";

    @FieldTypeAnnotation(desc = "商会UID", update = true)
    private String unionUid = "";

    @FieldTypeAnnotation(desc = "商会信息")
    private UnionBaseInfo unionBaseInfo = new UnionBaseInfo();

    @FieldTypeAnnotation(desc = "分数")
    private BigInteger value = BigInteger.ZERO;

    @FieldTypeAnnotation(desc = "额外参数")
    private String param = "";

    @FieldTypeAnnotation(desc = "更新时间")
    private long updateTime;

    @FieldTypeAnnotation(desc = "职位")
    private ConcurrentHashMap<Long, Integer> posMap = new ConcurrentHashMap<>();


    public void setInsertOption() {
        // 方便找哪里insert
        super.setInsertOption();
    }

    public void changeValue(BigInteger value, long updateTime) {
        if (!Objects.equals(value, getValue())) {
            setValue(value);
            setUpdateTime(updateTime);
        }
    }

    // --------------------------------------------------

    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        if (this.activityId != activityId) {
            this.activityId = activityId;
            setOp(DataStatus.Update);
        }
    }

    public int getGroupId() {
        return groupId;
    }

    public void setGroupId(int groupId) {
        if (this.groupId != groupId) {
            this.groupId = groupId;
            setOp(DataStatus.Update);
        }
    }

    public String getIdKey() {
        return idKey;
    }

    public void setIdKey(String idKey) {
        if (idKey == null) {
            return;
        }
        if (this.idKey == null || !this.idKey.equals(idKey)) {
            this.idKey = idKey;
            setOp(DataStatus.Update);
        }
    }

    public String getUnionUid() {
        return unionUid;
    }

    public void setUnionUid(String unionUid) {
        if (unionUid == null) {
            return;
        }
        if (this.unionUid == null || !this.unionUid.equals(unionUid)) {
            this.unionUid = unionUid;
            setOp(DataStatus.Update);
        }
    }

    public UnionBaseInfo getUnionBaseInfo() {
        return unionBaseInfo;
    }

    public void setUnionBaseInfo(UnionBaseInfo unionBaseInfo) {
        if (null == unionBaseInfo) {
            return;
        }
        if (this.unionBaseInfo == null || !this.unionBaseInfo.equals(unionBaseInfo)) {
            this.unionBaseInfo = unionBaseInfo;
            setOp(DataStatus.Update);
        }
    }

    public BigInteger getValue() {
        return value;
    }

    public void setValue(BigInteger value) {
        if (value == null) {
            return;
        }
        if (this.value == null || !this.value.equals(value)) {
            this.value = value;
            setOp(DataStatus.Update);
        }
    }

    public String getParam() {
        return param;
    }

    public void setParam(String param) {
        if (param == null) {
            return;
        }
        if (this.param == null || !this.param.equals(param)) {
            this.param = param;
            setOp(DataStatus.Update);
        }
    }

    public long getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(long updateTime) {
        if (this.updateTime != updateTime) {
            this.updateTime = updateTime;
            setOp(DataStatus.Update);
        }
    }

    public ConcurrentHashMap<Long, Integer> getPosMap() {
        return posMap;
    }

    public void setPosMap(ConcurrentHashMap<Long, Integer> posMap) {
        if (null == posMap) {
            return;
        }
        if (this.posMap == null || !this.posMap.equals(posMap)) {
            this.posMap = posMap;
            setOp(DataStatus.Update);
        }
    }
}
